package leetcode_day._2021._202104._0110;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/4/9 8:47
 * 寻找旋转排序数组中的最小值 II
 * 跟 33 题差不多，就是这道题数组元素是重复的
 * nums[mid] > nums[high] , low = mid + 1
 * nums[mid] < nums[high] , high = mid
 * nums[mid] == nums[high] , --high
 */
public class _09_154 {

    public int findMin(int[] nums) {
        int low = 0, high = nums.length - 1;
        while (low < high) {
            int mid = (low + high) >> 1;
            if (nums[mid] > nums[high]) low = mid + 1;
            else if (nums[mid] < nums[high]) high = mid;
            else --high;
        }
        return nums[low];
    }
}
